class Post < ActiveRecord::Base
  attr_accessible :content, :name, :title, :tags_attributes
validates :name,  :presence => true
  validates :title, :presence => true,
                    :length => { :minimum => 5 }
has_many :comments, :dependent => :destroy
has_many :tags

accepts_nested_attributes_for :tags, :allow_destroy => :true,
    :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } } 
end

class CreateComments < ActiveRecord::Migration
  def change
    create_table :comments do |t|
      t.string :commenter
      t.text :body
      t.references :post
 
      t.timestamps
    end
 
    add_index :comments, :post_id
  end
end



